package com.example.zerocopy.sendFile;

import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class Test {

	public static final String source = "F:\\copy\\1.txt";
	public static final String dest = "F:\\copy\\2.txt";

    public static void main(String[] args) {
    	try{
		    FileChannel sourceChannel = new RandomAccessFile(source, "rw").getChannel();
		    FileChannel destChannel = new RandomAccessFile(dest, "rw").getChannel();
		    long start = System.currentTimeMillis();
		    sourceChannel.transferTo(0, sourceChannel.size(), destChannel);
		    System.out.println("耗时：" + (System.currentTimeMillis() - start));
	    }catch (Exception e){

	    }
  }
}
